package leetcode.力扣竞赛.第327场周赛;

import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.stream.Collectors;

/**
 * @author: yan
 * @description: 执行 K 次操作后的最大分数
 * @create: 2023-02-22 17:12
 **/
public class Solution2530 {
    public long maxKelements(int[] nums, int k) {
        long res = 0;
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<Integer>((o1,o2)-> o2-o1);
        priorityQueue.addAll(Arrays.stream(nums).boxed().collect(Collectors.toList()));
        while(k-->0){
            int maxVar = priorityQueue.poll();
            res += maxVar;
            priorityQueue.offer((maxVar+2)/3);
        }
        return res;
    }
}
